package com.tg.service.eventbus2;

import com.google.common.eventbus.Subscribe;
import com.tg.service.eventbus2.entity.Event;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


public abstract class Component {

    private static final Logger LOGGER = LoggerFactory.getLogger(Component.class);

    protected abstract void invoke(Event event);

    /**
     * 消息总线执行handler
     */
    @Subscribe
    public void handle(Event event) {
        try {
            this.invoke(event);
        } catch (Exception ex) {
            LOGGER.error("总线异常", ex);
        }
    }
}
